#include <iostream>
#include <vector>
using namespace std;
class Solution {
 public:
  vector<int> temp;
  vector<vector<int>> ans;
  vector<vector<int>> findSubsequences(vector<int>& nums) {
    int len = nums.size();
    // sort(nums.begin(),nums.end());
    backtracking(nums, 0, len);
    return ans;
  }
  void backtracking(vector<int>& nums, int begin, int len) {
    int temp_len = temp.size();
    if (temp_len >= 2) ans.push_back(temp);
    if (len == temp_len) {
      return;
    }
    unordered_set<int> uset;  // 使用set对本层元素进行去重
    for (int i = begin; i < len; i++) {
      if ((!temp.empty() && nums[i] < temp.back()) ||
          uset.find(nums[i]) != uset.end()) {
        continue;
      }
      temp.push_back(nums[i]);
      uset.insert(nums[i]);
      backtracking(nums, i + 1, len);
      temp.pop_back();
    }
  }
};